import request from "@/lib/ajax";
import md5 from "js-md5";

// 获取当天活动
export  const  activityList = () =>{
  return request({
      url: '/api/spikeActivity/getActivityList',
  })
}
// 获取相关活动引导信息
export  const  getActivityGuidanceInfo = (id) =>{
  return request({
      url: '/api/spikeActivity/getActivityGuidanceInformation',
      method:'post',
      data: JSON.stringify({
        activity_id: id
      })
  })
}

// 参与秒杀活动
export const participateSpike = (id) => {
  return request({
    url:'/api/spikeActivity/participateSpike',
    method: 'post',
    data: JSON.stringify({
      activity_id : id
    })
  })
}


// 查询秒杀结果
export const queryResult  = (id) => {
  return request({
    url:'/api/spikeActivity/querySpikeResult',
    method:"post",
    data:JSON.stringify({
      spike_result_id:id
    })
  })
}
// 关注活动
export const actiAttention  = (id) => {
  return request({
    url:'/api/spikeActivity/attention',
    method:"post",
    data:JSON.stringify({
      activity_id:id
    })
  })
}
// 取消关注
export const cancelAttention  = (id) => {
  return request({
    url:'/api/spikeActivity/attention',
    method:"delete",
    data:JSON.stringify({
      activity_id:id
    })
  })
}
// 获取关注列表
export const getAttentionList  = () => {
  return request({
    url:'/api/spikeActivity/attention',
  })
}
// 查看关注与否
export const isAttention  = (id) => {
  return request({
    url:'/api/spikeActivity/isAttention',
    method:'post',
    data:JSON.stringify({
      activity_id:id,
    })
  })
}
//获取预秒杀结果
export const getResult  = (da) => {
  return request({
    url:'/api/spikeActivity/getSpikeResult',
    method:'post',
    data:JSON.stringify({
      activity_id:da.activity_id,
      product_id:da.product_id
    })
  })
}
// 获取秒杀活动验证码
export const getVerifyCode  = (id) => {
  return request({
    url:'/api/spikeActivity/getSpikeVerifyCode',
    method:'post',
    data:JSON.stringify({
      activity_id:id,
    })
  })
}

// 参与秒杀
export const participateActi  = (data,ss) => {
  let tt = md5("suse" + ss + "spike")
  return request({
    url:'/api/spikeActivity/participate/'+tt,
    method:'post',
    data:JSON.stringify({
      activity_id:data.activity_id,
      product_id:data.product_id,
      // verify_code:verify_code
    })
  })
}


